/*点赞接口*/
import { Message } from 'element-ui'
import { pubRequire } from '@utils/public'
const baseUrl = '/robots/likes'
/*点赞列表
obj = {
      topicType,//类型
      topicId,//类型对应的id
      pageSize,//页大小
      pageNum//页码
 * */
export function getLikesList(obj) {
  return new Promise((resolve, reject) => {
    let url = `/likes`
    pubRequire('get', url, obj, (response) => {
      resolve(response)
    })
  })
}
/* 加赞进度
obj = {
      categoryType,//类型
      topicId,//类型对应的id
      topicCreatedBy,//创建
 * */
export function praiseSpeed(obj) {
  return new Promise(
    (resolve, reject) => {
      let url = `${baseUrl}/progresses`
      pubRequire('get', url, obj, (response) => {
        resolve(response)
      })
    },
    (response) => {
      Message.warning(response.message)
    }
  )
}

/* 点赞
obj = {
  "topicId": "1083f6457dda4ebf98c1277022d0cc78",//类型对应的id
	"topicCreatedBy": "jxliqiwkbl",//创建人
	"topicType": "1", //点赞类型(批量点赞传:batch， 其他点赞类型传对应的点赞数量)
	"number": 1, //当前点赞数量
	"categoryType": 3, //类型
	"contentType": "VIDEO", //内容类型，TEXT/VIDEO
	"labels": "" //被点赞实体的标签（只有生活传值，其他模块非必传）
 * */
export function praises(obj) {
  return new Promise((resolve, reject) => {
    let url = `${baseUrl}`
    pubRequire(
      'post',
      url,
      obj,
      (response) => {
        resolve(true)
      },
      (response) => {
        Message.warning(response.message)
      }
    )
  })
}

/* 限时批量加赞
obj = {
  "topicId": "1083f6457dda4ebf98c1277022d0cc78",//类型对应的id
	"topicCreatedBy": "jxliqiwkbl",//创建人
	"topicType": "1", //点赞类型(批量点赞传:batch， 其他点赞类型传对应的点赞数量)
	"number": 1, //当前点赞数量
	"categoryType": 3, //类型
	"contentType": "VIDEO", //内容类型TEXT/VIDEO
	"labels": "",//只有生活传值，其他模块非必传
   "startTime":"2020-05-18 10:20:30" //限制时间（限时批量点赞设置的时间）

 * */
export function timePraise(obj) {
  return new Promise((resolve, reject) => {
    let url = `${baseUrl}/time-praise?type=time-limit`
    pubRequire(
      'post',
      url,
      obj,
      (response) => {
        resolve(true)
      },
      (response) => {
        Message.warning(response.message)
      }
    )
  })
}

/* 取消点赞
obj = {
  "topicId": "1083f6457dda4ebf98c1277022d0cc78",//类型对应的id
	"categoryType": 3, //类型
   "topicCreatedBy": "jxliqiwkbl"//创建人
 * */
export function cancelPraises(obj) {
  return new Promise((resolve, reject) => {
    let url = `${baseUrl}`
    pubRequire(
      'delete',
      url,
      obj,
      (response) => {
        resolve(true)
      },
      (response) => {
        Message.warning(response.message)
      }
    )
  })
}
